﻿namespace RuoVea.CodeGen.Server.Models;

/// <summary>
/// 元数据字段表。
/// </summary>
[SugarTable(nameof(GenFieldMetadata), "元数据字段表")]
public class GenFieldMetadata : EntityBaseId
{ 
    /// <summary>
    /// 表Id
    /// </summary>
    [SugarColumn(IsNullable = false)]
    public long TableMetaId { get; set; }

    /// <summary>
    /// 获取或设置列名。
    /// </summary>
    public string DbColumnName { get; set; }


    /// <summary>
    /// 获取或设置列的别名。
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public string PropertyName { get; set; }

    /// <summary>
    /// 字段长度
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public int Length { get; set; }

    /// <summary>
    /// 获取或设置数据类型。
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public string DataType { get; set; }


    /// <summary>
    /// 实体类类型
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public string PropertyType { get; set; }

    /// <summary>
    /// 字段描述
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public string Description { get; set; }

    /// <summary>
    /// 默认值
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public string DefaultValue { get; set; }

    /// <summary>
    /// 获取或设置一个值，指示该列是否允许NULL。
    /// 默认为不允许NULL。
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public bool IsNullable { get; set; } = false;

    /// <summary>
    /// 获取或设置一个值，指示该列是否为主键。
    /// 默认为非主键。
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public bool IsPrimaryKey { get; set; } = false;

    /// <summary>
    /// 自增
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public bool IsIdentity { get; set; } = false;

    /// <summary>
    /// 获取或设置排序号。
    /// 默认为0。
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public int FieldSort { get; set; } = 0;

    /// <summary>
    /// 
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public int? DecimalDigits { get; set; }
    /// <summary>
    /// 
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public int? SpecialType { get; set; }

    /// <summary>
    /// 
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public bool IsJson { get; set; }

    /// <summary>
    /// 
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public bool IsIgnore { get; set; }
    
    /// <summary>
    /// 子项
    /// </summary>
    [SugarColumn(IsIgnore = true)]

    [Navigate(NavigateType.OneToOne, nameof(Id))]
    public GenFieldMetadataExAvue? ExAvue { get; set; }


    /// <summary>
    /// 是否为搜索项
    /// </summary>
    [Display(Name = "是否为搜索项")]
    public bool? IsSearch { get; set; } = false;

    /// <summary>
    /// 表格列中是否显示
    /// </summary>
    [Display(Name = "表格列中是否显示")]
    public bool? ColumnDisplay { get; set; } = true;

    /// <summary>
    /// 表单新增时项是否显示
    /// </summary>
    [Display(Name = "表单新增时项是否显示")]
    public bool? AddDisplay { get; set; } = true;

    /// <summary>
    /// 表单编辑时项是否显示
    /// </summary>
    [Display(Name = "表单编辑时项是否显示")]
    public bool? EditDisplay { get; set; } = true;

    /// <summary>
    /// 
    /// </summary>
    public CellTypeEnum CellType { get; set; }
    
}

public enum CellTypeEnum
{
    input,
    /// <summary>
    /// Number数字输入框
    /// </summary>
    number,
    /// <summary>
    /// 选择框 同时配置dicData为字典值
    /// </summary>
    select,
    /// <summary>
    /// 级联选择器 ,同时配置dicData为字典值,通过expandTrigger可以定义展开子级菜单的触发方式,默认为hover
    /// </summary>
    cascader,
    /// <summary>
    /// 多选框,同时配置dicData为字典值
    /// </summary>
    checkbox,
    /// <summary>
    /// 单选框 ,同时配置dicData为字典值
    /// </summary>
    radio,
    /// <summary>
    /// 日期   快捷选项需配置pickerOptions对象中的shortcuts，禁用日期通过 disabledDate 设置，传入函数
    /// </summary>
    datetime,
    /// <summary>
    /// 时间 
    /// </summary>
    time,
    /// <summary>
    /// 开关,同时配置dicData为字典值
    /// </summary>
    @switch,
    /// <summary>
    /// 附件上传
    /// </summary>
    upload,
    /// <summary>
    /// 图标选择器 配置iconList属性
    /// </summary>
    icon,
    /// <summary>
    /// 
    /// </summary>
    color,
    /// <summary>
    /// 评价
    /// </summary>
    rate,
    /// <summary>
    /// 滑块
    /// </summary>
    slider,

}
